import { createRouter, createWebHashHistory } from 'vue-router'
import NProgress from 'nprogress'//导入nprogress.js
import 'nprogress/nprogress.css'//导入nprogress的样式
import Index from '../views/Index.vue';
import Login from '../views/Login.vue';
import Layout from '../views/Layout.vue';
import Family from '../views/Family.vue';
import FamilyShow from '../views/FamilyShow.vue';



//定义路由信息的数组
const routes = [
 { path:'/',component:Index },  //配置首页
 { path:'/login',component:Login }, //登录页
 { path:'/layout', component:Layout,
    children:[
    {
        path:'/layout/family',component:Family,  
   },
   {
     path:'/layout/familyshow',component:FamilyShow,
   }
  ]
 
}, //布局页
 
]
//创建一个路由器对象
const router = createRouter({
  history: createWebHashHistory(),
  routes
})
//定义路由导航前置守卫
router.beforeEach((to,from,next)=>{
  NProgress.start();
  next()
})
//定义路由导航后置守卫
router.afterEach((to,from,)=>{
  NProgress.done();
})

export default router
